<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/template.xhtml">


    <ui:define name="title">
        DataExporter <span class="subitem">Basic</span>
    </ui:define>

    <ui:define name="description">
        EXCEL, PDF, CSV and XML are the supported formats. The datatable columns content will be justified as left aligned, center aligned and right aligned based on the content type.
        If a style or styleClass contains the word "right" the cell will be right aligned in the Excel/PDF output.
    </ui:define>

    <ui:param name="documentationLink" value="/components/dataexporter"/>

    <ui:define name="implementation">
        <div class="card">
            <h:form>
                <div class="flex justify-content-between">
                    <div>
                        <h5>Standard</h5>
                        <p:commandButton value="XLS" styleClass="mr-2 mb-2">
                            <p:dataExporter type="xls" target="tbl" fileName="products"/>
                        </p:commandButton>
    
                        <p:commandButton value="XLSX" styleClass="mr-2 mb-2">
                            <p:dataExporter type="xlsxstream" target="tbl" fileName="products"/>
                        </p:commandButton>
    
                        <p:commandButton value="PDF" styleClass="mr-2 mb-2">
                            <p:dataExporter type="pdf" target="tbl" fileName="products"/>
                        </p:commandButton>
    
                        <p:commandButton value="CSV" styleClass="mr-2 mb-2">
                            <p:dataExporter type="csv" target="tbl" fileName="products" />
                        </p:commandButton>
    
                        <p:commandButton value="XML" styleClass="mr-2 mb-2">
                            <p:dataExporter type="xml" target="tbl" fileName="products"/>
                        </p:commandButton>
    
                        <p:commandButton value="TXT" styleClass="mr-2 mb-2">
                            <p:dataExporter type="txt" target="tbl" fileName="products" exporter="#{dataExporterView.textExporter}"/>
                        </p:commandButton>
                    </div>

                    <div>
                        <h5>Page Only</h5>
                        <p:commandButton value="XLS" styleClass="mr-2 mb-2 ui-button-outlined">
                            <p:dataExporter type="xls" target="tbl" fileName="products" pageOnly="true"/>
                        </p:commandButton>
        
                        <p:commandButton value="XLSX" styleClass="mr-2 mb-2 ui-button-outlined">
                            <p:dataExporter type="xlsxstream" target="tbl" fileName="products" pageOnly="true"/>
                        </p:commandButton>
        
                        <p:commandButton value="PDF" styleClass="mr-2 mb-2 ui-button-outlined">
                            <p:dataExporter type="pdf" target="tbl" fileName="products" pageOnly="true"/>
                        </p:commandButton>
        
                        <p:commandButton value="CSV" styleClass="mr-2 mb-2 ui-button-outlined">
                            <p:dataExporter type="csv" target="tbl" fileName="products" pageOnly="true"/>
                        </p:commandButton>
        
                        <p:commandButton value="XML" styleClass="mr-2 mb-2 ui-button-outlined">
                            <p:dataExporter type="xml" target="tbl" fileName="products" pageOnly="true"/>
                        </p:commandButton>
        
                        <p:commandButton value="TXT" styleClass="mr-2 mb-2 ui-button-outlined">
                            <p:dataExporter type="txt" target="tbl" fileName="products" pageOnly="true"
                                            exporter="#{dataExporterView.textExporter}"/>
                        </p:commandButton>
                    </div>
                </div>

                <p:dataTable id="tbl" var="product" value="#{dataExporterView.products}"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                             paginator="true" rows="10" styleClass="mt-2">
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Code"/>
                        </f:facet>
                        <h:outputText value="#{product.code}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Name"/>
                        </f:facet>
                        <h:outputText value="#{product.name}"/>
                    </p:column>

                    <p:column  styleClass="text-center">
                        <f:facet name="header">
                            <h:outputText value="Category"/>
                        </f:facet>
                        <h:outputText value="#{product.category}"/>
                    </p:column>

                    <p:column styleClass="text-right">
                        <f:facet name="header">
                            <h:outputText value="Quantity"/>
                        </f:facet>
                        <h:outputText value="#{product.quantity}"/>
                    </p:column>

                    <p:column styleClass="text-right">
                        <f:facet name="header">
                            <h:outputText value="Price"/>
                        </f:facet>
                        <h:outputText value="#{product.price}">
                            <f:convertNumber type="currency" />
                        </h:outputText>
                    </p:column>
                </p:dataTable>
            </h:form>
        </div>
    </ui:define>

    <ui:define name="more-source-tabs">
        <p:tab title="/org/primefaces/showcase/view/data/dataexporter/TextExporter.java"/>
    </ui:define>

</ui:composition>
